# 构建阶段：使用华为云OpenJDK 8 JDK镜像（需SpringBoot项目兼容Java 8）
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/openjdk:8u342-jdk as build
WORKDIR /app
COPY mvnw .
COPY .mvn .mvn
COPY pom.xml .
RUN ./mvnw dependency:resolve
COPY src ./src
RUN ./mvnw package -DskipTests


FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/openjdk:8u342-jdk
WORKDIR /app
COPY --from=build /app/target/*.jar app.jar

ENV SPRING_DATASOURCE_URL=jdbc:mysql://db:3306/jenkins \
    SPRING_DATASOURCE_USERNAME=root \
    SPRING_DATASOURCE_PASSWORD=xiao
EXPOSE 8080
CMD ["java", "-jar", "app.jar"]
